package com.zhou.cloud.config;

import com.zhou.cloud.entiry.Computer;
import com.zhou.cloud.entiry.Cpu;

import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @descrition:
 * @author: zhouyongjun
 * @date: 2022/9/30
 **/
@Configuration
@Slf4j
public class BeanConfig {

    @Bean
    public Computer computer() {
        log.warn("<<<<<<<< new computer...");
        return new Computer();
    }

    @Bean
    @ConditionalOnBean(Computer.class)
    public Cpu cpu() {
        log.warn("<<<<<<<< new cpu...");
        return new Cpu();
    }

    @Bean
    @ConditionalOnMissingBean(Computer.class)
    public Cpu cpu2() {
        log.warn("<<<<<<<< new cpu2...");
        return new Cpu();
    }




}
